<!DOCTYPE html>
<html lang="">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta itemprop="name" content="gitea&#43;drone配置自动化部署">
<meta itemprop="description" content="git &#43; drone搭建项目自动部署 step1：下载安装gitea  docker-compose.yml
 version: &#34;3.7&#34;networks:www:external: trueservices:gitea:image: gitea/gitea:1.16.9container_name: giteaenvironment:- USER_UID=1000- USER_GID=1000- DB_TYPE=mysql- DB_HOST= mysql:3306- DB_NAME=gitea- DB_USER=root- DB_PASSWD=lican520restart: alwaysnetworks:- wwwvolumes:- ./gitea:/data- ./etc/timezone:/etc/timezone:ro- ./etc/localtime:/etc/localtime:roexpose:- 22- 3000logging:driver: json-fileoptions:max-size: &#34;100M&#34; # 单个文件大小为200k max-file: &#34;10&#34; # 最多10个文件 注意：当docker-compose无法拉取gitea安装包时，可以从gitea.tar拉取，我们通过
docker save -o gitea.">
<meta itemprop="datePublished" content="2024-07-04T14:00:28&#43;08:00" />
<meta itemprop="dateModified" content="2024-07-04T14:00:28&#43;08:00" />
<meta itemprop="wordCount" content="453">



<meta itemprop="keywords" content="" /><meta property="og:title" content="gitea&#43;drone配置自动化部署" />
<meta property="og:description" content="git &#43; drone搭建项目自动部署 step1：下载安装gitea  docker-compose.yml
 version: &#34;3.7&#34;networks:www:external: trueservices:gitea:image: gitea/gitea:1.16.9container_name: giteaenvironment:- USER_UID=1000- USER_GID=1000- DB_TYPE=mysql- DB_HOST= mysql:3306- DB_NAME=gitea- DB_USER=root- DB_PASSWD=lican520restart: alwaysnetworks:- wwwvolumes:- ./gitea:/data- ./etc/timezone:/etc/timezone:ro- ./etc/localtime:/etc/localtime:roexpose:- 22- 3000logging:driver: json-fileoptions:max-size: &#34;100M&#34; # 单个文件大小为200k max-file: &#34;10&#34; # 最多10个文件 注意：当docker-compose无法拉取gitea安装包时，可以从gitea.tar拉取，我们通过
docker save -o gitea." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://www.lican.site/postsbak/gitea&#43;drone%E6%90%AD%E5%BB%BA%E9%A1%B9%E7%9B%AE%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/" />
<meta property="article:published_time" content="2024-07-04T14:00:28+08:00" />
<meta property="article:modified_time" content="2024-07-04T14:00:28+08:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="gitea&#43;drone配置自动化部署"/>
<meta name="twitter:description" content="git &#43; drone搭建项目自动部署 step1：下载安装gitea  docker-compose.yml
 version: &#34;3.7&#34;networks:www:external: trueservices:gitea:image: gitea/gitea:1.16.9container_name: giteaenvironment:- USER_UID=1000- USER_GID=1000- DB_TYPE=mysql- DB_HOST= mysql:3306- DB_NAME=gitea- DB_USER=root- DB_PASSWD=lican520restart: alwaysnetworks:- wwwvolumes:- ./gitea:/data- ./etc/timezone:/etc/timezone:ro- ./etc/localtime:/etc/localtime:roexpose:- 22- 3000logging:driver: json-fileoptions:max-size: &#34;100M&#34; # 单个文件大小为200k max-file: &#34;10&#34; # 最多10个文件 注意：当docker-compose无法拉取gitea安装包时，可以从gitea.tar拉取，我们通过
docker save -o gitea."/>

	<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
	<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
	<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
	<link rel="manifest" href="/site.webmanifest">
	<link rel="mask-icon" href="/safari-pinned-tab.svg" color="">
	<link rel="shortcut icon" href="/favicon.ico">

	<title>gitea&#43;drone配置自动化部署</title>
	<link rel="stylesheet" href="https://www.lican.site/css/style.min.d3141168199607bf3a517216ce3c263814eecdbc8fca72a9a88700799a838219.css">
	
</head>

<body id="page">
	
	<header id="site-header" class="animated slideInUp faster">
		<div class="hdr-wrapper section-inner">
			<div class="hdr-left">
				<div class="site-branding">
					<a href="https://www.lican.site">花落雨忧</a>
				</div>
				<nav class="site-nav hide-in-mobile">
					<a href="https://www.lican.site/posts">首页</a>
					<a href="https://www.lican.site/tech/">技术文档</a>
					<a href="https://www.lican.site/article/">文章</a>
					<a href="https://www.lican.site/project/">项目</a>
					<a href="https://www.lican.site/about/">关于</a>
				</nav>
			</div>
			<div class="hdr-right hdr-icons">
				<button id="menu-btn" class="hdr-btn" title="Menu"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></button>
			</div>
		</div>
	</header>
	<div id="mobile-menu" class="animated fast">
		<ul>
			<li><a href="https://www.lican.site/posts">首页</a></li>
			<li><a href="https://www.lican.site/tech/">技术文档</a></li>
			<li><a href="https://www.lican.site/article/">文章</a></li>
			<li><a href="https://www.lican.site/project/">项目</a></li>
			<li><a href="https://www.lican.site/about/">关于</a></li>
		</ul>
	</div>


	<main class="site-main section-inner thin animated fadeIn faster">
		<h1>gitea&#43;drone配置自动化部署</h1>
		<div class="content">
			<h3 id="git--drone搭建项目自动部署">git + drone搭建项目自动部署<a href="#git--drone搭建项目自动部署" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a></h3>
<h4 id="step1下载安装gitea">step1：下载安装gitea<a href="#step1下载安装gitea" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a></h4>
<blockquote>
<p>docker-compose.yml</p>
</blockquote>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml"><span style="color:#66d9ef">version</span>: <span style="color:#e6db74">&#34;3.7&#34;</span>
networks:
  www:
    <span style="color:#66d9ef">external</span>: <span style="color:#66d9ef">true</span>
services:
  gitea:
    <span style="color:#66d9ef">image</span>: gitea/gitea:<span style="color:#ae81ff">1.16.9</span>
    <span style="color:#66d9ef">container_name</span>: gitea
    environment:
      - USER_UID=<span style="color:#ae81ff">1000</span>
      - USER_GID=<span style="color:#ae81ff">1000</span>
      - DB_TYPE=mysql
      - DB_HOST= mysql:<span style="color:#ae81ff">3306</span>
      - DB_NAME=gitea
      - DB_USER=root
      - DB_PASSWD=lican520
    <span style="color:#66d9ef">restart</span>: always
    networks:
      - www
    volumes:
      - ./gitea:/data
      - ./etc/timezone:/etc/timezone:ro
      - ./etc/localtime:/etc/localtime:ro
    expose:
      - <span style="color:#ae81ff">22</span>
      - <span style="color:#ae81ff">3000</span>
    logging:
      <span style="color:#66d9ef">driver</span>: json-file
      options:
         <span style="color:#66d9ef">max-size</span>: <span style="color:#e6db74">&#34;100M&#34;</span> <span style="color:#75715e"># 单个文件大小为200k</span>
         <span style="color:#66d9ef">max-file</span>: <span style="color:#e6db74">&#34;10&#34;</span> <span style="color:#75715e"># 最多10个文件</span>
</code></pre></div><p>注意：当docker-compose无法拉取gitea安装包时，可以从<a href="https://pan.baidu.com/s/1geZWmAslEEevfs5yWlCFzA?pwd=1234">gitea.tar</a>拉取，我们通过</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">docker</span> <span style="color:#a6e22e">save</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">o</span> <span style="color:#a6e22e">gitea</span>.<span style="color:#a6e22e">tar</span> <span style="color:#a6e22e">gitea</span><span style="color:#f92672">/</span><span style="color:#a6e22e">gitea</span>:<span style="color:#ae81ff">1.16.9</span>
</code></pre></div><p>保存的安装包，下载后， 仅需docker load -i gitea.tar即可</p>
<blockquote>
<p>安装之前，需要先安装一个mysql容器，gitea依赖mysql存储</p>
</blockquote>
<p>服务启动后，可以配置nginx转发，配置域名，通过域名访问</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">server</span> {
  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">80</span>;
  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">443</span> <span style="color:#a6e22e">ssl</span>;
  <span style="color:#a6e22e">ssl_certificate</span>      .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">fullchain</span>.<span style="color:#a6e22e">pem</span>;
  <span style="color:#a6e22e">ssl_certificate_key</span>  .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">key</span>.<span style="color:#a6e22e">pem</span>;
  <span style="color:#a6e22e">server_name</span> <span style="color:#a6e22e">git</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span>;
  <span style="color:#66d9ef">if</span> (<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">args</span> <span style="color:#960050;background-color:#1e0010">~</span><span style="color:#f92672">*</span> <span style="color:#e6db74">&#34;^go-get=1&#34;</span>) {
    <span style="color:#a6e22e">set</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">condition</span> <span style="color:#a6e22e">goget</span>;
  }
  <span style="color:#66d9ef">if</span> (<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">uri</span> <span style="color:#960050;background-color:#1e0010">~</span> ^<span style="color:#f92672">/</span>([<span style="color:#a6e22e">a</span><span style="color:#f92672">-</span><span style="color:#a6e22e">zA</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Z0</span><span style="color:#f92672">-</span><span style="color:#ae81ff">9</span><span style="color:#a6e22e">_</span><span style="color:#f92672">-</span>]<span style="color:#f92672">+</span>)<span style="color:#f92672">/</span>([<span style="color:#a6e22e">a</span><span style="color:#f92672">-</span><span style="color:#a6e22e">zA</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Z0</span><span style="color:#f92672">-</span><span style="color:#ae81ff">9</span><span style="color:#a6e22e">_</span><span style="color:#f92672">-</span>]<span style="color:#f92672">+</span>)<span style="color:#f92672">/</span>.<span style="color:#f92672">*</span><span style="color:#960050;background-color:#1e0010">$</span>) {
    <span style="color:#a6e22e">set</span> <span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">condition</span> <span style="color:#e6db74">&#34;${condition}path&#34;</span>;
  }
  <span style="color:#66d9ef">if</span> (<span style="color:#960050;background-color:#1e0010">$</span><span style="color:#a6e22e">condition</span> = <span style="color:#a6e22e">gogetpath</span>) {
    <span style="color:#66d9ef">return</span> <span style="color:#ae81ff">200</span> <span style="color:#e6db74">&#34;&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta content=&#39;git.nongbotech.com/$1/$2 git https://git.nongbotech.com/$1/$2.git&#39; name=&#39;go-import&#39;&gt;&lt;/head&gt;&lt;/html&gt;&#34;</span>;
  }
  <span style="color:#a6e22e">location</span> <span style="color:#f92672">/</span> {
       <span style="color:#a6e22e">add_header</span> <span style="color:#a6e22e">Access</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Control</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Allow</span><span style="color:#f92672">-</span><span style="color:#a6e22e">Origin</span> <span style="color:#f92672">*</span>;
       <span style="color:#a6e22e">proxy_pass</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//gitea:3000;
</span><span style="color:#75715e"></span>  }
}
</code></pre></div><p>通过域名访问后，配置数据库登录参数，即可来到登录页面，登录后，可创建代码仓库</p>
<p><img src="C:%5CUsers%5CAdministrator%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5C1720062673243.png" alt="1720062673243"></p>
<p>创建gitea和drone授权应用</p>
<p>右上角-&gt;设置-&gt;应用-&gt;创建应用</p>
<p>应用名称：自定义,我暂且填drone</p>
<p>重定向URL: 跳转到drone的地址，为drone访问地址加上/login,例如我配置的drone访问地址是https://drone.nongbotech.com. 所以此处填写https://drone.nongbotech.com/login</p>
<blockquote>
<p>创建完gitea应用后，会有客户端ID,和客户端密钥</p>
</blockquote>
<h4 id="step-2-下载安装drone-server和drone-runner">step 2: 下载安装drone-server和drone-runner<a href="#step-2-下载安装drone-server和drone-runner" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a></h4>
<blockquote>
<p>docker-compose.yml</p>
</blockquote>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">version</span>: <span style="color:#960050;background-color:#1e0010">&#39;</span><span style="color:#ae81ff">3.7</span><span style="color:#960050;background-color:#1e0010">&#39;</span>
<span style="color:#a6e22e">services</span>:
  <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">server</span>:
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span>:<span style="color:#ae81ff">2.8.0</span>
    <span style="color:#a6e22e">container_name</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">server</span>
    <span style="color:#a6e22e">ports</span>:
      <span style="color:#f92672">-</span> <span style="color:#e6db74">&#34;3003:3000&#34;</span>
    <span style="color:#a6e22e">volumes</span>:
      <span style="color:#f92672">-</span> .<span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">data</span>
      <span style="color:#f92672">-</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">localtime</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">localtime</span>:<span style="color:#a6e22e">ro</span>
    <span style="color:#a6e22e">environment</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_USER_CREATE</span>=<span style="color:#a6e22e">username</span>:<span style="color:#a6e22e">lican</span>,<span style="color:#a6e22e">admin</span>:<span style="color:#66d9ef">true</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GITEA_CLIENT_ID</span>=<span style="color:#a6e22e">bcb76646</span><span style="color:#f92672">-</span><span style="color:#ae81ff">56</span><span style="color:#a6e22e">b0</span><span style="color:#f92672">-</span><span style="color:#ae81ff">42</span><span style="color:#a6e22e">ab</span><span style="color:#f92672">-</span><span style="color:#ae81ff">8</span><span style="color:#a6e22e">f11</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ecd2e5a1bea2</span> <span style="color:#75715e">// gitea应用的客户端ID
</span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GITEA_CLIENT_SECRET</span>=<span style="color:#ae81ff">0</span><span style="color:#a6e22e">VHtKBja73k6Oe7yMGGzbfOvogjKYITpiOzsmoHej6X1</span> <span style="color:#75715e">// gitea应用的客户端密钥
</span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GITEA_SERVER</span>=<span style="color:#a6e22e">http</span>:<span style="color:#75715e">//git.nongbotech.com  #gitea访问地址
</span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_GIT_ALWAYS_AUTH</span>=<span style="color:#66d9ef">false</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_SECRET</span>=<span style="color:#ae81ff">50</span><span style="color:#a6e22e">f491d1154873d72f3cedc710d01d59</span> <span style="color:#75715e">// drone-server和drone-runner间的通信密钥，可通过指令生成[openssl rand -hex 16]
</span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_SERVER_HOST</span>=<span style="color:#a6e22e">drone</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span>  <span style="color:#75715e">// drone访问地址
</span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_SERVER_PROTO</span>=<span style="color:#a6e22e">https</span>
    <span style="color:#a6e22e">restart</span>: <span style="color:#a6e22e">always</span>
    <span style="color:#a6e22e">networks</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">www</span>
  <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">runner</span>:
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">runner</span><span style="color:#f92672">-</span><span style="color:#a6e22e">docker</span>:<span style="color:#ae81ff">1.8.0</span>
    <span style="color:#a6e22e">container_name</span>: <span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">runner</span>
    <span style="color:#a6e22e">volumes</span>:
      <span style="color:#f92672">-</span> <span style="color:#f92672">/</span><span style="color:#66d9ef">var</span><span style="color:#f92672">/</span><span style="color:#a6e22e">run</span><span style="color:#f92672">/</span><span style="color:#a6e22e">docker</span>.<span style="color:#a6e22e">sock</span>:<span style="color:#f92672">/</span><span style="color:#66d9ef">var</span><span style="color:#f92672">/</span><span style="color:#a6e22e">run</span><span style="color:#f92672">/</span><span style="color:#a6e22e">docker</span>.<span style="color:#a6e22e">sock</span>
    <span style="color:#a6e22e">environment</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_PROTO</span>=<span style="color:#a6e22e">https</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_HOST</span>=<span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">server</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RPC_SECRET</span>=<span style="color:#ae81ff">50</span><span style="color:#a6e22e">f491d1154873d72f3cedc710d01d59</span> <span style="color:#75715e">// drone-server和drone-runner间的通信密钥，可通过指令生成[openssl rand -hex 16]
</span><span style="color:#75715e"></span>      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RUNNER_CAPACITY</span>=<span style="color:#ae81ff">3</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RUNNER_NAME</span>=<span style="color:#a6e22e">drone_runner</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_CPU_SHARES</span>=<span style="color:#ae81ff">300</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_MEMORY_LIMIT</span>=<span style="color:#ae81ff">2000000000</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">DRONE_RUNNER_VOLUMES</span>=.<span style="color:#f92672">/</span><span style="color:#a6e22e">nbi_dev</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">www_dev</span>
    <span style="color:#a6e22e">restart</span>: <span style="color:#a6e22e">always</span>
    <span style="color:#a6e22e">networks</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">www</span>
<span style="color:#a6e22e">networks</span>:
  <span style="color:#a6e22e">www</span>:
    <span style="color:#a6e22e">external</span>: <span style="color:#66d9ef">true</span>
</code></pre></div><p><a href="https://pan.baidu.com/s/19tuKOxt9sP-mVxp0He3YRQ?pwd=1234">drone-server.tar</a></p>
<p><a href="https://pan.baidu.com/s/1GBDCYSu36dNbAZrR06GLCA?pwd=1234">drone-server.tar</a></p>
<p><a href="https://juejin.cn/post/7145763787201593381">配置参数指引</a></p>
<p>配置nginx转发drone服务</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">server</span> {
  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">80</span>;
  <span style="color:#a6e22e">listen</span> <span style="color:#ae81ff">443</span> <span style="color:#a6e22e">ssl</span>;
  <span style="color:#a6e22e">ssl_certificate</span>      .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">fullchain</span>.<span style="color:#a6e22e">pem</span>;
  <span style="color:#a6e22e">ssl_certificate_key</span>  .<span style="color:#f92672">/</span><span style="color:#a6e22e">ssl</span><span style="color:#f92672">/*</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span><span style="color:#f92672">/</span><span style="color:#a6e22e">key</span>.<span style="color:#a6e22e">pem</span>;
  <span style="color:#a6e22e">server_name</span> <span style="color:#a6e22e">drone</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">com</span>;
  <span style="color:#a6e22e">location</span> <span style="color:#f92672">/</span> {
    <span style="color:#a6e22e">proxy_pass</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//drone-server:80;
</span><span style="color:#75715e"></span>  }
}
</code></pre></div><p>1.drone-server和drone-runner服务启动后， 点击右上角的SYNC按钮即可同步gitea刚刚创建的代码仓库</p>
<p>2.点击同步到的代码仓库，进入页面后点击Settings按钮</p>
<ul>
<li>
<p>General: 最下面一行配置超时时间和钩子执行的.drone.yml文件</p>
</li>
<li>
<p>Secrets: 配置drone访问服务器的基本参数，该参数在.drone.yml文件中通过该变量访问服务器</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Remark</th>
</tr>
</thead>
<tbody>
<tr>
<td>DRONE_SSH_HOST</td>
<td>120.77.213.80</td>
<td>服务器ip地址</td>
</tr>
<tr>
<td>DRONE_SSH_USER</td>
<td>root</td>
<td>用户名</td>
</tr>
<tr>
<td>DRONE_SSH_PORT</td>
<td>22</td>
<td>端口号</td>
</tr>
<tr>
<td>DRONE_SSH_KEY</td>
<td>&mdash;&ndash;BEGIN OPENSSH PRIVATE KEY&mdash;&ndash;</td>
<td></td>
</tr>
<tr>
<td>&mdash;&ndash;END OPENSSH PRIVATE KEY&mdash;&ndash;</td>
<td>服务器访问私钥&mdash;&mdash;&ndash;登录服务器后，通过运行指令ssh-keygen -t rsa -b 4096生成后，进入~/.ssh后，打开id_rsa文件，复制可得</td>
<td></td>
</tr>
</tbody>
</table>
<p>配置完成之后，推送代码到gitea的仓库中，即可看到触发了drone的运行，需要在项目的指定位置放置.drone.yml文件</p>
<p>.drone.yml文件示例</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">kind</span>: <span style="color:#a6e22e">pipeline</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">对象类型</span>
<span style="color:#66d9ef">type</span>: <span style="color:#a6e22e">docker</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道类型</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">drone支持不同的类型</span>
<span style="color:#a6e22e">name</span>: <span style="color:#e6db74">&#34;brewing-sass&#34;</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道名称</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">一个项目可以有多个管道</span>
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">克隆设置</span>
<span style="color:#a6e22e">clone</span>:
  <span style="color:#a6e22e">disable</span>: <span style="color:#66d9ef">true</span>
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">触发条件</span>
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">trigger</span>:
<span style="color:#960050;background-color:#1e0010">#</span>  <span style="color:#a6e22e">event</span>:
<span style="color:#960050;background-color:#1e0010">#</span>    <span style="color:#f92672">-</span> <span style="color:#a6e22e">tag</span>
<span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道步骤</span>
<span style="color:#a6e22e">steps</span>:
  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">base</span><span style="color:#f92672">-</span><span style="color:#a6e22e">setup</span>
  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">基础后台设置服务</span>
  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">clone</span>
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">alpine</span><span style="color:#f92672">/</span><span style="color:#a6e22e">git</span>
    <span style="color:#a6e22e">environment</span>:
      <span style="color:#a6e22e">GOOS</span>: <span style="color:#a6e22e">linux</span>
      <span style="color:#a6e22e">GOARCH</span>: <span style="color:#a6e22e">amd64</span>
    <span style="color:#a6e22e">commands</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">git</span> <span style="color:#a6e22e">clone</span> <span style="color:#a6e22e">http</span>:<span style="color:#75715e">//git.dev.nongbotech.cn/back-end-3.0/brewing-sass.git brewing-sass
</span><span style="color:#75715e"></span>    <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">编译</span>
  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">build</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">管道步骤名称</span>
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">golang</span>:<span style="color:#ae81ff">1.16.9</span> <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">执行shell命令的docker镜像</span>
    <span style="color:#a6e22e">environment</span>:
      <span style="color:#a6e22e">GOOS</span>: <span style="color:#a6e22e">linux</span>
      <span style="color:#a6e22e">GOARCH</span>: <span style="color:#a6e22e">amd64</span>
    <span style="color:#a6e22e">commands</span>: <span style="color:#960050;background-color:#1e0010">#</span><span style="color:#a6e22e">定义在docker容器内作为容器入口点执行的shell命令列表</span>
      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">env</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">w</span> <span style="color:#a6e22e">GOPRIVATE</span>=<span style="color:#a6e22e">git</span>.<span style="color:#a6e22e">dev</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">cn</span>
      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">env</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">w</span> <span style="color:#a6e22e">GOPROXY</span>=<span style="color:#a6e22e">https</span>:<span style="color:#75715e">//goproxy.cn
</span><span style="color:#75715e"></span>      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">get</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">u</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">v</span> <span style="color:#a6e22e">git</span>.<span style="color:#a6e22e">dev</span>.<span style="color:#a6e22e">nongbotech</span>.<span style="color:#a6e22e">cn</span><span style="color:#f92672">/</span><span style="color:#a6e22e">back</span><span style="color:#f92672">-</span><span style="color:#a6e22e">end</span><span style="color:#f92672">-</span><span style="color:#ae81ff">3.0</span><span style="color:#f92672">/</span><span style="color:#a6e22e">pkg</span>
      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">get</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">u</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">v</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">gopkg</span><span style="color:#f92672">/</span><span style="color:#a6e22e">logger</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">cd</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span>
      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">mod</span> <span style="color:#a6e22e">tidy</span>
      <span style="color:#f92672">-</span> <span style="color:#66d9ef">go</span> <span style="color:#a6e22e">build</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">o</span> <span style="color:#a6e22e">brewing_sass_app</span>
  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">发布</span>
  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">publish</span>
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">appleboy</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">scp</span>
    <span style="color:#a6e22e">settings</span>:
      <span style="color:#a6e22e">host</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_HOST</span>
      <span style="color:#a6e22e">port</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_PORT</span>
      <span style="color:#a6e22e">user</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_USER</span>
      <span style="color:#a6e22e">key</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_KEY</span>
      <span style="color:#a6e22e">target</span>: <span style="color:#f92672">/</span><span style="color:#a6e22e">data</span><span style="color:#f92672">/</span><span style="color:#a6e22e">nbi_dev</span><span style="color:#f92672">/</span><span style="color:#a6e22e">soa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">dev</span><span style="color:#f92672">-</span><span style="color:#a6e22e">soa_backend</span><span style="color:#f92672">/</span><span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span>
      <span style="color:#a6e22e">source</span>:
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">app</span>.<span style="color:#a6e22e">yaml</span>
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">rsa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">private</span>.<span style="color:#a6e22e">pem</span>
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span><span style="color:#f92672">/</span><span style="color:#a6e22e">rsa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">public</span>.<span style="color:#a6e22e">pem</span>
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span><span style="color:#f92672">/</span><span style="color:#a6e22e">brewing_sass_app</span>
      <span style="color:#a6e22e">strip_components</span>: <span style="color:#ae81ff">1</span> <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">去除前缀</span>
  
  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">服务重启</span>
  <span style="color:#f92672">-</span> <span style="color:#a6e22e">name</span>: <span style="color:#a6e22e">brewing</span><span style="color:#f92672">-</span><span style="color:#a6e22e">sass</span> <span style="color:#a6e22e">reboot</span>
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">appleboy</span><span style="color:#f92672">/</span><span style="color:#a6e22e">drone</span><span style="color:#f92672">-</span><span style="color:#a6e22e">ssh</span>
    <span style="color:#a6e22e">settings</span>:
      <span style="color:#a6e22e">host</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_HOST</span>
      <span style="color:#a6e22e">port</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_PORT</span>
      <span style="color:#a6e22e">username</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_USER</span>
      <span style="color:#a6e22e">key</span>:
        <span style="color:#a6e22e">from_secret</span>: <span style="color:#a6e22e">DRONE_SSH_KEY</span>
      <span style="color:#a6e22e">script</span>:
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">cd</span> <span style="color:#f92672">/</span><span style="color:#a6e22e">data</span><span style="color:#f92672">/</span><span style="color:#a6e22e">nbi_dev</span><span style="color:#f92672">/</span><span style="color:#a6e22e">soa</span><span style="color:#f92672">/</span><span style="color:#a6e22e">dev</span><span style="color:#f92672">-</span><span style="color:#a6e22e">soa_backend</span>
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">docker</span><span style="color:#f92672">-</span><span style="color:#a6e22e">compose</span> <span style="color:#a6e22e">down</span>
        <span style="color:#f92672">-</span> <span style="color:#a6e22e">docker</span><span style="color:#f92672">-</span><span style="color:#a6e22e">compose</span> <span style="color:#a6e22e">up</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">d</span>
  
</code></pre></div></li>
</ul>

		</div>
	</main>

	<footer id="site-footer" class="section-inner thin animated fadeIn faster">
		<p>&copy; 2024 <a href="https://www.lican.site"></a></p>
		<p>
			Made with <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> &#183; Theme <a href="https://github.com/Track3/hermit" target="_blank" rel="noopener">Hermit</a> &#183; <a href="https://www.lican.site/post/index.xml" target="_blank" title="rss"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss"><path d="M4 11a9 9 0 0 1 9 9"></path><path d="M4 4a16 16 0 0 1 16 16"></path><circle cx="5" cy="19" r="1"></circle></svg></a>
		</p>
	</footer>


	<script src="https://www.lican.site/js/main.min.784417f5847151f848c339cf0acb13a06cbb648b1483435a28ed4556c4ead69b.js"></script>

</body>

</html>
